package cn.edu.scau.cmi.liujianxun.client.fxUI.singleton;

import cn.edu.scau.cmi.liujianxun.singleton.Chairman;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
public class SingletonDemoController {
	@FXML
	private TextArea text;
	@FXML
	private Button bt1;
	@FXML
	private Button bt2;
	
	public SingletonDemoController() {
		
	}
	
	public void bt1Event() {
		String name = "毛泽东";
		if(Chairman.getInstance(name) == null) {
			text.appendText("创建成功，主席名字为" + Chairman.getName() + "\n");
		}
		else {
			text.appendText("创建失败，主席已存在，主席名字为" + Chairman.getName().toString() + "\n");
		}
	}
	
	public void bt2Event() {
		if(Chairman.getInstance(null) == null) {
			text.appendText("尚未创建主席\n");
		}
		else {
			text.appendText("主席名字为" + Chairman.getName().toString() + "\n");
		}
	}
}
